package com.fifth.home.controller;

import com.fifth.common.pojo.dto.CommonResult;
import com.fifth.common.pojo.entity.Zone;
import com.fifth.home.pojo.vo.ZoneBus;
import com.fifth.home.service.IZoneBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 专区课程关联表 前端控制器
 * </p>
 * @author 第五组
 * @since 2022-09-05
 */
@RestController
@RequestMapping("/home/zoneBusiness")
@Api(tags = "专区商家接口")
public class ZoneBusinessController {
    @Autowired
    private IZoneBusinessService zoneBusinessService;

    /**
     * 查询专区管理所有已上架 带分页 带模糊查询
     * @param zoneBus
     * @return
     */
    @ApiOperation("查询专区店铺接口(后台调用)")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "zoneBus",value = "ZoneBus实体类",dataType = "ZoneBus"),
                    @ApiImplicitParam(name = "currentPage",value = "当前页码",dataType = "int"),
                    @ApiImplicitParam(name = "pageSize",value = "每页条数",dataType = "int")
            }
    )
    @PostMapping("managementZone/{currentPage}/{pageSize}")
    public CommonResult managementZone(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody ZoneBus zoneBus){
        return zoneBusinessService.managementZoneAndBusiness(currentPage,pageSize,zoneBus);
    }

    /**
     * 查询专区管理所有未上架商店 带分页 带模糊查询   新增弹出层
     * @param zoneBus
     * @return
     */
    @ApiOperation("新增专区店铺回显接口(后台调用)")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "zoneBus",value = "ZoneBus实体类",dataType = "ZoneBus"),
                    @ApiImplicitParam(name = "currentPage",value = "当前页码",dataType = "int"),
                    @ApiImplicitParam(name = "pageSize",value = "每页条数",dataType = "int")
            }
    )
    @PostMapping("manageUnstockedStores/{currentPage}/{pageSize}")
    public CommonResult manageUnstockedStores(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody ZoneBus zoneBus){
        return zoneBusinessService.manageUnstockedZoneAndBusiness(currentPage,pageSize,zoneBus);
    }

    /**
     * 添加  修改未上架的状态
     * @param id
     * @return
     */
    @ApiOperation("修改未上架店铺状态接口(后台新增调用)")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "id",value = "ZoneBusiness的id属性",dataType = "String",required = true)
            }
    )
    @GetMapping("addBusinessDetail/{id}")
    public CommonResult addBusinessDetail(@PathVariable String id){
        return zoneBusinessService.addBusinessPutaway(id);
    }

    /**
     * 修改上下架状态
     * @param id
     * @param isDisable
     * @return
     */
    @ApiOperation("修改专区店铺状态(后台调用)")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "id",value = "ZoneBusiness的id属性",dataType = "String"),
                    @ApiImplicitParam(name = "isDisable",value = "状态 0启动 1禁用",dataType = "String")
            }
    )
    @GetMapping("changeStatus/{id}/{isDisable}")
    public CommonResult changeStatus(@PathVariable String id,@PathVariable String isDisable){
        return zoneBusinessService.changeIsDisable(id,isDisable);
    }

    /**
     * 修改排序
     * @param id
     * @param sort
     * @return
     */
    @ApiOperation("修改店铺排序接口(后台调用)")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "id",value = "ZoneBusiness的id属性",dataType = "String"),
                    @ApiImplicitParam(name = "sort",value = "排序顺序",dataType = "Integer")
            }
    )
    @GetMapping("changeSort/{id}/{sort}")
    public CommonResult changeSort(@PathVariable String id, @PathVariable Integer sort){
        return zoneBusinessService.changeSort(id,sort);
    }

    /**
     * 删除上架 商家
     * @param id
     * @return
     */
    @ApiOperation("删除专区商家接口(后台调用)")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "id",value = "ZoneBusiness的id属性",dataType = "String")
            }
    )
    @GetMapping("deleteZoneBusiness/{id}")
    public CommonResult deleteZoneBusiness(@PathVariable String id){
        return zoneBusinessService.deleteZoneBusinessById(id);
    }

    /**
     * 前端查询商家每个专区的前四个
     */
    @ApiOperation("查询专区前四个商家接口(前端调用)")
    @GetMapping("selectZoneBusiness")
    public CommonResult selectZoneBusiness(){
        return zoneBusinessService.selectZoneBusiness();
    }

    /**
     * 前端查询所有商家
     */
    @ApiOperation("查询专区商家接口(前端调用)")
    @GetMapping("selectAllZoneBusiness")
    public CommonResult selectAllZoneBusiness(){
        return zoneBusinessService.selectAllZoneBusiness();
    }


    @PostMapping("findBusinessByName")
    public CommonResult findBusinessByName( String chandVal, Integer pageCurrent, Integer pageSize){
        System.out.println(chandVal);
        return zoneBusinessService.selectBusinessByName(pageCurrent,pageSize,chandVal);
    }

}
